package com.app.allwe.gui;

import com.app.allwe.gui.countdown.CountdownThread;
import com.app.allwe.gui.countdown.TimeLabel;
import com.app.allwe.gui.panle.BasePanel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.swing.*;

@Component
public class FrameService {

    @Value("${time}")
    private Integer TIME;

    @Value("${pic.icon.path}")
    private String picPath;

    @Resource
    private BaseFrame baseFrame;

    @Resource
    private BasePanel basePanel;

    public void createBaseFrame() throws InterruptedException {
        // 初始化窗体
        baseFrame.setIconImage(new ImageIcon(picPath).getImage());
        baseFrame.add(basePanel);
        baseFrame.setVisible(true);

        // 刷新倒计时
        CountdownThread countdownThread = new CountdownThread(TIME, TimeLabel.getTimeLabel());
        countdownThread.start();

        Thread.sleep(TIME * 1000);
        baseFrame.dispose();
    }
}
